import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:geomancy/enums/index.dart';
import 'package:geomancy/mock/wealth_data.dart';
import 'package:geomancy/styles/index.dart';
import 'package:geomancy/tools/constant.dart';
import 'package:geomancy/tools/utils.dart';
import 'package:geomancy/widgets/common_header.dart';
import 'package:geomancy/widgets/common_text.dart';
import 'package:geomancy/widgets/common_title.dart';
import 'package:geomancy/widgets/direction_grid/index.dart';
import 'package:geomancy/widgets/star_grid/index.dart';
import 'package:go_router/go_router.dart';

class WealthResultPage extends StatefulWidget {
  final CompassSource source;
  ///罗盘角度
  final double direction;
  const WealthResultPage({super.key, required this.source, required this.direction});

  @override
  State<WealthResultPage> createState() => _WealthResultPageState();
}

class _WealthResultPageState extends State<WealthResultPage> {
  late String themeTxt;
  late String station;
  List<int> indexList = [];

  @override
  void initState() {
    super.initState();
    themeTxt = widget.source == CompassSource.roomWealth ? '房间' : '工位';
    station = Utils.getCompassStation(widget.direction);
    indexList = WealthData.gridData[station]['indexList'];
  }

  backHandle() {
    context.go('/');
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: CommonHeader.appBar(context: context),
      backgroundColor: ColorStyle.pageDefaultColor,
      body: ListView(
        physics: const ClampingScrollPhysics(),
        padding: EdgeInsets.fromLTRB(Constant.PAGEPADDING.w, 20.w, Constant.PAGEPADDING.w, 80.w),
        children: [
          CommonTitleWidget(txt: '$themeTxt财运位'),
          Container(
            height: 160.w,
            margin: EdgeInsets.symmetric(vertical: 20.w),
            padding: EdgeInsets.symmetric(horizontal: 40.w),
            alignment: Alignment.center,
            decoration: BoxDecoration(
                color: ColorStyle.themeLightColor,
                border: Border.all(width: 5.w, color: ColorStyle.borderColor),
                borderRadius: BorderRadius.all(Radius.circular(60.w))
            ),
            child: CommonText(txt: '所测$themeTxt财运位方位如下，地支三合、地支六合详情请点击财运位查看。', height: 1.5),
          ),
          DirectionGridWidget(
            activeList: indexList,
            isOpacity: widget.source == CompassSource.stationWealth,
            source: widget.source,
            direction: widget.direction,
          ),
          Container(
            margin: EdgeInsets.only(bottom: 80.w, top: 40.w),
            padding: EdgeInsets.symmetric(vertical: 30.w, horizontal: 40.w),
            decoration: BoxDecoration(
                color: ColorStyle.themeLightColor,
                border: Border.all(width: 5.w, color: ColorStyle.borderColor),
                borderRadius: BorderRadius.all(Radius.circular(60.w))
            ),
            child: Column(
              crossAxisAlignment: CrossAxisAlignment.start,
              children: [
                const CommonText(txt: '催动财位的方法：', height: 1.5, weight: FontWeight.bold),
                CommonText(height: 1.5, txt: '1.若所测$themeTxt财运位与本年度流年飞星中的六白武曲星或八白左辅星相重合，则本年度财运位将达到最佳效果，本年度宜进行催动。'),
                CommonText(height: 1.5, txt: '2.若所测$themeTxt财运位与本年度流年飞星中的二黑巨门星、三碧禄存星、五黄廉贞星或七赤破军星方位相重合，则本年度不宜对$themeTxt财位进行催动。'),
                const CommonText(height: 1.5, txt: '3.催动财运位，可在此方位布置：沙发、浴缸或盆栽来增加生气和聚集能量。'),
              ],
            ),
          ),
          CommonTitleWidget(txt: '${Utils.getCurrentYear()}年 九宫飞星财运位'),
          Container(
            margin: EdgeInsets.only(top: 20.w),
            child: const StarGridWidget(activeList: [1, 2]),
          ),
        ],
      ),
    );
  }
}
